package com.haizhi.crm.biz.task.message.transfer.impl;

import com.haizhi.crm.biz.model.MessageClientDo;
import com.haizhi.crm.biz.task.message.model.ContextDto;
import com.haizhi.crm.biz.task.message.transfer.TransferService;

import java.util.Map;

/**
 * Created by wangshan on 2018/5/23.
 */
public class InnerEventTransfer implements TransferService {

    private static final String CUSTOMER_KEY = "customer_key";
    private static final String DETAIL_KEY = "detail_key";
    private static final String NAME = "title";
    private static final String TYPE = "sub_type";

    @Override
    public ContextDto transfer(Map<String, String> data) {
        ContextDto contextDto = new ContextDto();
        contextDto.setEventType(data.get(TYPE));
        contextDto.setDetailKey(data.get(DETAIL_KEY));
        MessageClientDo messageClientDo = new MessageClientDo();
        messageClientDo.setCompanyId(data.get(CUSTOMER_KEY));
        contextDto.getMessageClientDos().add(messageClientDo);
        contextDto.setTitle(data.get(NAME));
        return contextDto;
    }
}
